|
Ok!
|
|
|
Ok!
|
---|---|---|---|---|
112 | $r = GetCountries(); print_r($r); Array ( [0] => Array ( [ID] => 1 [CODE] => RU [NAME] => Россия ) [1] => Array ( [ID] => 2 [CODE] => AZ [NAME] => Азербайджан ) ) | страны, страна, битрикс, массив | 100 | Получить массив стран в Битрикс |
24 | $rs_Section = CIBlockSection::GetList( array('DEPTH_LEVEL' => 'desc'), $ar_Filter, false, array('ID', 'NAME', 'IBLOCK_SECTION_ID', 'DEPTH_LEVEL', 'SORT') ); $ar_SectionList = array(); $ar_DepthLavel = array(); while($ar_Section = $rs_Section->GetNext(true, false)) { $ar_SectionList[$ar_Section['ID']] = $ar_Section; $ar_DepthLavel[] = $ar_Section['DEPTH_LEVEL']; } $ar_DepthLavelResult = array_unique($ar_DepthLavel); rsort($ar_DepthLavelResult); $i_MaxDepthLevel = $ar_DepthLavelResult[0]; for( $i = $i_MaxDepthLevel; $i > 1; $i-- ) { foreach ( $ar_SectionList as $i_SectionID => $ar_Value ) { if( $ar_Value['DEPTH_LEVEL'] == $i ) { $ar_SectionList[$ar_Value['IBLOCK_SECTION_ID']]['SUB_SECTION'][] = $ar_Value; unset( $ar_SectionList[$i_SectionID] ); } } } function __sectionSort($a, $b) { if ($a['SORT'] == $b['SORT']) { return 0; } return ($a['SORT'] < $b['SORT']) ? -1 : 1; } usort($ar_SectionList, "__sectionSort"); | битрикс, массив, перебор | 780 | Перебор массива Битрикс в виде дерева |
6 | foreach($quest['METRO'] as $n => $station) echo ($n > 0 ? ', ' : '').$station['VALUE_ENUM']; | через запятую, массив, элементы | 40 | Элементы массива, выводимые через запятую. Очень элегантное решение |